﻿using System;
using System.Text;

namespace SharpSqlAnalyzer.pp.logger
{
	// Token: 0x0200026D RID: 621
	public class PPLogger
	{
		// Token: 0x06001373 RID: 4979 RVA: 0x0031EEC0 File Offset: 0x0031D0C0
		public static void error(Exception e)
		{
			PPLogger.logger.doLog(new PPLoggerRecord(100, null, e));
		}

		// Token: 0x06001374 RID: 4980 RVA: 0x0031EED5 File Offset: 0x0031D0D5
		public static void info(Exception e)
		{
			PPLogger.info(null, e);
		}

		// Token: 0x06001375 RID: 4981 RVA: 0x0031EEDE File Offset: 0x0031D0DE
		public static void info(string msg)
		{
			PPLogger.info(msg, null);
		}

		// Token: 0x06001376 RID: 4982 RVA: 0x0031EEE7 File Offset: 0x0031D0E7
		public static void info(string msg, Exception e)
		{
			PPLogger.info(0, msg, null);
		}

		// Token: 0x06001377 RID: 4983 RVA: 0x0031EEF1 File Offset: 0x0031D0F1
		public static void info(int stackLevel, string msg, Exception e)
		{
			PPLogger.logger.doLog(new PPLoggerRecord(300, stackLevel, msg, e));
		}

		// Token: 0x06001378 RID: 4984 RVA: 0x0031EF0C File Offset: 0x0031D10C
		private void doLog(PPLoggerRecord record)
		{
			if (PPLogger.currLogLevel == 0)
			{
				return;
			}
			if (PPLogger.currLogLevel >= record.LogLevel)
			{
				StringBuilder stringBuilder = new StringBuilder();
				stringBuilder.Append(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"));
				int logLevel = record.LogLevel;
				if (logLevel != 100)
				{
					if (logLevel == 300)
					{
						stringBuilder.Append(" INFO: ");
					}
				}
				else
				{
					stringBuilder.Append(" ERROR: ");
				}
				if (record.Msg != null)
				{
					stringBuilder.Append("\n").Append(record.Msg);
				}
				Console.Error.WriteLine(stringBuilder);
				if (record.E != null)
				{
					Console.WriteLine(record.E.ToString());
					Console.Write(record.E.StackTrace);
				}
				Console.Error.Write("\n");
			}
		}

		// Token: 0x040014A1 RID: 5281
		public const int OFF = 0;

		// Token: 0x040014A2 RID: 5282
		public const int INFO = 300;

		// Token: 0x040014A3 RID: 5283
		public const int ERROR = 100;

		// Token: 0x040014A4 RID: 5284
		public static int currLogLevel = 0;

		// Token: 0x040014A5 RID: 5285
		private static PPLogger logger = new PPLogger();
	}
}
